import axios from "axios";

const baseUrl = "http://localhost:8080";

const taskRequest={

    loadTaskByProjectId(projectId,parentId = 0,callBack){
        if (projectId){
            axios.get(baseUrl + "/task/list/?projectId="+projectId+"&parentId="+parentId)
                .then(res =>{
                    callBack(res.data)
                })
        }
    },
    save(task,callBack){
        axios.post(baseUrl + "/task/save",task)
            .then(res=>callBack(res.data));
    },
    getById(taskId,callBack){
        axios.get(baseUrl + "/task/get?taskId="+taskId)
            .then(res=>callBack(res.data));
    },
    update(task,callBack){
        axios.put(baseUrl + "/task/update/" + task.taskId,task)
            .then(res =>callBack(res.data))
    },
    delete(taskId,callBack){
        axios.put(baseUrl + "/task/delete/" + taskId)
            .then(res =>callBack(res.data))
    }
}
export default taskRequest;